package com.example.tfliteonwatch;


import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;

public class chooseModel extends AppCompatActivity {

    private TextView mTextView;

    private Button  model1;
    private Button  model2;
    private Button  model3;
    private Button  confirm;

    public void addModel(String model){
        para.modellist.add(model);
    }
    public void deleteModel(String model){
        para.modellist.remove(para.modellist.indexOf(model));
    }
    static int boolToInt(boolean b) {
        if(b)
            return 1;
        return 0;
    }
    public void afterclick(Button b){
        Log.d("",b.getText().toString().split(" ")[0]);
        switch (boolToInt(para.action.contains(b.getText().toString().split(" ")[0]))){
            case 0:
//                        PPG.setActivated(false);
                addModel(b.getText().toString());
                b.setBackgroundResource(R.drawable.shape2);

                break;
            case 1:
//                        PPG.setActivated(true);
                Log.d("","点过了");
                deleteModel(b.getText().toString());
                b.setBackgroundResource(R.drawable.shape);

                break;
        }

    }



    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        para.setTimeIndex=0;




        setContentView(R.layout.activity_choose_model);
        Log.d("","jinlaile");
        model1=(Button) findViewById(R.id.model1);
        model1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                afterclick(model1);
            }
        });

        model2=(Button) findViewById(R.id.model2);
        model2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                afterclick(model2);
//                setAction(1);
//                Intent intent=new Intent(action.this, setTime.class);
//                startActivity(intent);
            }
        });

        model3=(Button) findViewById(R.id.model3);
        model3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                afterclick(model3);
//                setAction(2);
//                Intent intent=new Intent(action.this, setTime.class);
//                startActivity(intent);
            }
        });

        confirm=(Button) findViewById(R.id.confirm);
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                for(String i :para.modellist){
                    Log.d("",i);
                }
//                setAction(7);



                Intent intent=new Intent(chooseModel.this, chooseStart.class);

                startActivity(intent);
            }
        });

    }
}